<!--
 * @Author: your name
 * @Date: 2021-09-10 11:32:41
 * @LastEditTime: 2021-09-13 14:58:33
 * @LastEditors: LAPTOP-JN5U4VA6
 * @Description: In User Settings Edit     
 * @FilePath: \ej-webui\src\pages\examine\orderComment.vue
-->
<template>
  <div class="production">
    <div class="btns">
      <!-- 检索框 -->
      <el-form :inline="true" :model="params" size="small">
        <el-form-item>
          <el-input clearable v-model="params.content" placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input clearable v-model="params.orderId" placeholder="请输入订单编号"></el-input>
        </el-form-item>
        <el-form-item>
          <el-select clearable v-model="params.status" placeholder="请选择状态">
            <el-option label="未审核" value="未审核"></el-option>
            <el-option label="通过" value="通过"></el-option>
            <el-option label="不通过" value="不通过"></el-option>
          </el-select>
        </el-form-item>
        <el-button
          type="primary"
          size="small"
          style="margin-right: 10px"
          @click="pageQueryProductions"
          icon="el-icon-search"
          >查询</el-button
        >
      </el-form>
    </div>
    <div class="content">
      <!-- 表格 -->
      <el-table :data="resData.list" style="width: 100%" size="small"  ref="multipleTable">
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column label="评论内容" prop="content"></el-table-column>
        <el-table-column label="顾客编号" prop="customerId">

        </el-table-column>
        <el-table-column label="订单编号" prop="orderId"></el-table-column>
        <el-table-column label="评论时间" prop="commentTime">
          <template v-slot="scope">
            {{scope.row.commentTime | fmtDate}}
          </template>
        </el-table-column>
        <el-table-column label="评论状态" prop="status">
          <template v-slot="scope">
            <el-tag
              v-if="scope.row.status == '通过'"
              size="mini"
              type="success"
              >{{ scope.row.status }}</el-tag>
              <el-tag
              v-else-if="scope.row.status == '不通过'"
              size="mini"
              type="danger"
              >{{ scope.row.status }}</el-tag>
            <el-tag v-else size="mini" type="info">{{
              scope.row.status
            }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template v-slot="scope">
            <el-button type="text" size="small" @click="editHandler(scope.row.id,$event)">通过</el-button>
            <!-- <el-button type="text" v-else size="small" @click="editHandler(scope.row.id,$event)">不通过</el-button> -->
            <el-button type="text" size="small" @click="delHandler(scope.row.id)" style="color: red">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <!-- total表示：数据的总条数  current-page表示：当前所在的页数   -->
      <el-pagination
        background
        layout="prev, pager, next, sizes"
        :total="resData.total"
        :page-size="params.pageSize"
        :current-page="params.page"
        @current-change="pageChangeHandler"
        :page-sizes="[5, 10, 15]"
        @size-change="pageSizeChangeHandler"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
import { mapActions } from "vuex";
import qs from "qs";
import _ from "lodash";

export default {
  data() {
    return {
      params: {
        page: 1,
        pageSize: 5,
      },
      resData: {},
      categories: [],
      title: "",
      production: {},
    }
  },
  methods: {
    // 导入状态机中的方法
    ...mapActions("category", ["findAllCategories"]),
    // 分页查询产品表格
    async pageQueryProductions() {
      // 过滤数据将空字符串删除
      for (let key in this.params) {
        if (this.params[key] == "") {
          delete this.params[key];
        }
      }
      let res = await request.get("/orderComment/pageQuery", {
        params: this.params,
      });
      this.resData = res.data;
    },
    // page改变事件  
    pageChangeHandler(page) {
      // 将更新了的页码传递给页面   并且刷新查询到的对应页码上的内容
      this.params.page = page;
      this.pageQueryProductions();
    },
    // pageSize改变事件  pageSize是每页中显示的数据条目
    pageSizeChangeHandler(pageSize) {
      this.params.pageSize = pageSize;
      this.pageQueryProductions();
    },

    // 关闭模态框的回调函数
    dialogCloseHandler() {
      // 置空表单验证
      this.$refs["saveForm"].resetFileds();
    },

    // 审核  事件
    editHandler(id,e) {
      
    },
    

    // 删除 事件
    delHandler(id) {
        this.$confirm('此操作将永久删除该基础配置, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
        }).then(() => {
            request.get('/orderComment/deleteById',{ params:{id} }).then((res) => {
                // 刷新数据
                this.pageQueryProductions();
                this.$message({
                    type: "success",
                    message: res.message,
                }); // 提示成功信息
            })

        })
    },
    
  },
  created() {
    this.pageQueryProductions(); // 分页查询产品
    this.findAllCategories().then((res) => {
      this.categories = res.data.list;
    }); // 查询所有产品栏目
  },
};
</script>

<style scoped>

</style>